package com.c.ctgproject.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.PartsSellListEntity
import com.c.ctgproject.utils.handlerNull


/**
 * 作者:LiBW
 * 创建日期: 2020/9/9
 * 描述:配件销售列表适配器
 */
class PartSellListAdapter(private val context: Context, private val mList: List<PartsSellListEntity.DataBean.ListBean>) : RecyclerView.Adapter<PartSellListAdapter.ViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_part_sell, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }


    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = mList[position]

        holder.mCarPlateTV.text = data.ownerPlate.handlerNull()
        holder.mTimeTV.text = data.outTime.handlerNull()
        holder.mPartNameTV.text = data.partsName.handlerNull()
        holder.mPriceTV.text = data.partsPrice.handlerNull()
        holder.mPartCountTV.text = data.partsNumber.handlerNull()
        holder.mPartWeightTV.text = data.partsWeight.handlerNull()
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mCarPlateTV: TextView = itemView.findViewById(R.id.mOrderIdTV)
        val mTimeTV: TextView = itemView.findViewById(R.id.mTimeTV)
        val mPartNameTV: TextView = itemView.findViewById(R.id.mPartNameTV)
        val mPriceTV: TextView = itemView.findViewById(R.id.mPriceTV)
        val mPartCountTV: TextView = itemView.findViewById(R.id.mPartCountTV)
        val mPartWeightTV: TextView = itemView.findViewById(R.id.mPartWeightTV)
    }
}